package com.sec.android.app.myfiles.feature;

import com.sec.android.app.myfiles.feature.sidesync.SidesyncImp;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;

import android.content.Context;

import java.util.ArrayList;

public class SidesyncMgr {
    public static final String SIDESYNC_KMS_SINK_SERVICE_CLASS = "com.sec.android.sidesync.kms.sink.service.SideSyncServerService";
    public static final String SIDESYNC_KMS_SOURCE_SERVICE_CLASS = "com.sec.android.sidesync.kms.source.service.SideSyncService";

    private SidesyncImp mSidesyncImp;

    private static SidesyncMgr sInstance;

    public static SidesyncMgr getInstance() {
        if (sInstance == null) {
            sInstance = new SidesyncMgr();
        }

        return sInstance;
    }

    private SidesyncMgr() {
        mSidesyncImp = new SidesyncImp();
    }

    public boolean isConnected(Context context) {
        boolean bRet = false;

        if (mSidesyncImp != null) {
            bRet = mSidesyncImp.isKMSRunning(context) || mSidesyncImp.isSourceConnected(context) || mSidesyncImp.isSLinkConnected(context);
        }

        return bRet;
    }

    public boolean isSlinkConnected(Context context) {
        boolean bRet = false;
        if (mSidesyncImp != null) {
            bRet = mSidesyncImp.isSLinkConnected(context);
        }
        return bRet;
    }

    public void onDragSidesyncToList(Context context, FileRecord record) {
        if (mSidesyncImp != null) {
            mSidesyncImp.onDragSidesyncToList(context, record);
        }
    }

    public void onDragListToSidesync(Context context, ArrayList<FileRecord> recordList) {
        if (mSidesyncImp != null) {
            if (mSidesyncImp.isSourceConnected(context)) {
                mSidesyncImp.onDragToPss(context, recordList);
            }else if (mSidesyncImp.isKMSRunning(context)) {
                mSidesyncImp.onDragListToKms(context, recordList);
            }
        }
    }
}
